题目描述
输入一棵二叉树,判断该二叉树是否是平衡二叉树。
import java.util.*;
public class Solution {
public int _Depth_Solution(TreeNode root) {
if(root == null)
return 0;
int left = _Depth_Solution(root.left) + 1;
int right = _Depth_Solution(root.right) + 1;
return (left > right) ? left : right;
}
public boolean IsBalanced_Solution(TreeNode root) {
if(root == null)
return true;
Stack<TreeNode> stack = new Stack();
stack.push(root);
while(!stack.isEmpty()){
TreeNode cur = stack.pop();
int l = _Depth_Solution(cur.left);
int r = _Depth_Solution(cur.right</